package ru.amse.tsyganov.jumleditor.model;

import org.w3c.dom.Element;
import org.w3c.dom.Node;



public abstract class State extends ModelElement {
	
	private static final String NAME = "name";

	private final StateVertex stateVertex = new StateVertex(this);
	
	private ActivityGraph activityGraph;
	
	private String name = "";
	
	public final StateVertex getStateVertex() {
		return stateVertex;
	}

	public final ActivityGraph getActivityGraph() {
		return activityGraph;
	}

	public void setActivityGraph(ActivityGraph activityGraph) {
		if (activityGraph == null) {
			throw new IllegalArgumentException();
		}
		this.activityGraph = activityGraph;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void readFromXml(Node element) {
		setName(element.getAttributes().getNamedItem(
				NAME).getNodeValue());
	}

	public void writeToXml(Element element) {
		element.setAttribute(NAME, getName());
	}
}
